package com.weipai.springboot.module.dao.impl;
//import com.sun.tools.corba.se.idl.StringGen;
import com.weipai.springboot.model.Article;
import com.weipai.springboot.model.ArticleCategory;
import com.weipai.springboot.module.dao.ArticleDao;
import com.weipai.springboot.module.mapper.ArticleCategoryMapper;
import com.weipai.springboot.module.mapper.ArticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 * Created by ${lyh} on 2018/8/27.
 */
@Repository
public class ArticleDaoImpl implements ArticleDao{


    @Autowired
    private ArticleMapper articleMapper;
    @Autowired
    private ArticleCategoryMapper articleCategoryMapper;

    //查询新闻列表
    @Override
    public List<Article> selectAllByArticle(int articleStatus, String search, String way, String categoryId) {
        return articleMapper.selectAllByArticle(articleStatus, search, way, categoryId);
    }

    @Override
    public Article getArticleById(String articleId) {
        return articleMapper.selectByPrimaryKey(articleId);
    }

    //修改
    @Override
    public int updateArticle(Article article) {
        return articleMapper.updateByPrimaryKeySelective(article);
    }

    //保存
    @Override
    public int save(Article article) {
        return articleMapper.insertSelective(article);
    }

    //文章的删除
    @Override
    public int delete(String articleId) {
        return articleMapper.deleteByPrimaryKey(articleId);
    }

    //文章分类列表
    @Override
    public List<ArticleCategory> articleCategoryList() {
        return articleCategoryMapper.articleCategoryList();
    }
}
